package com.orphan.marketFront.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.orphan.marketFront.po.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * <p>
 * 快速注册的用户的数据表 Mapper 接口
 * </p>
 *
 * @author lucangtian
 * @since 2021-07-12
 */
@Repository
public interface UserMapper extends BaseMapper<User> {

    //根据用户名查询用户
    @Select("select * from t_user where user_name = #{userName}")
    public User getUserByName(String userName);

    //添加用户账号、密码(注册)
    @Insert("insert into t_user (user_name,password,real_name,gender,tel)  values (#{userName}, #{password}, #{realName}, #{gender}, #{tel})")
    public int addUser(User user);

    //根据用户名查询用户
    @Select("select user_name from t_user where u_id = #{id}")
    public String getUserNameById(Long id);
}
